package com.xbongbong.pro.message.model.impl;/*/*/

import com.xbongbong.message.domain.dao.PushLinkDao;
import com.xbongbong.message.domain.entity.PushLinkEntity;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import com.xbongbong.pro.message.model.PushLinkModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * Description: PushLinkModel 实现
 * @author 魏荣杰
 * @date 2019/1/6 1:14
 * @version v1.0
 * @since v1.0
 */
@Service("PushLinkModel")
public class PushLinkModelImpl implements PushLinkModel {

    @Resource
    private PushLinkDao pushLinkDao;

    @Override
    public Integer insert(PushLinkEntity entity) throws XbbException {
        Long now = DateTimeUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return pushLinkDao.insert(entity);
    }

    @Override
    public Integer update(PushLinkEntity entity) throws XbbException {
        entity.setUpdateTime(DateTimeUtil.getInt());
        return pushLinkDao.update(entity);
    }

    @Override
    public List<PushLinkEntity> findEntitys(Map<String, Object> param) {
        return pushLinkDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return pushLinkDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

    @Override
    public void insertBatch(ArrayList<PushLinkEntity> pushLinkList) {
        pushLinkDao.insertBatch(pushLinkList);
    }

    @Override
    public Integer save(PushLinkEntity entity) throws XbbException {
        if (entity.getId() == null || Objects.equals(0L, entity.getId())) {
            return insert(entity);
        }
        return update(entity);
    }

    @Override
    public Integer deleteByKey(Integer key, String corpid) {
        return pushLinkDao.deleteByKey(key, corpid);
    }

    @Override
    public PushLinkEntity getByKey(Integer key, String corpid) {
        return pushLinkDao.getByKey(key, corpid);
    }

    @Override
    public void readPushList(Map<String, Object> param) {
        pushLinkDao.readPushList(param);
    }

    @Override
    public void deletePushList(Map<String, Object> param) {
        pushLinkDao.deletePushList(param);
    }

    @Override
    public void readAllPushLink(Map<String, Object> param) {
        pushLinkDao.readAllPushLink(param);
    }

    @Override
    public Integer deleteByPushIdIn(List<Long> pushIds, String corpid) {
        return pushLinkDao.deleteByPushIdIn(pushIds, corpid);
    }

    @Override
    public void apartTeam2DeleteMessage(Map<String, Object> param) {
        pushLinkDao.apartTeam2DeleteMessage(param);
    }
}
